<?php
/*************************************************************************
Manage update config module
----------------------------------------------------------------
Derasoft CMS Project
Company: Derasoft Co., Ltd                                  
Name: Tran Thi Kim Que                                  
Last updated: 8/01/2010
**************************************************************************/
ini_set('display_errors','1'); ini_set('display_startup_errors','1'); 
include_once(ROOT_PATH."classes/dao/configs.class.php");
include_once(ADMIN_ROOT_PATH.'includes/functions.php');
$templateFile = "adminupdategeneralConfig.temp.html";
$infoText = '';
$infoClass = "InfoText";
$configs = new Configs();
$config = $configs->getObject("general");
if($_POST) {
	# Validation
	include_once(ROOT_PATH."classes/data/validate.class.php");
	 $validate = validateData($request);
	if($validate == '') {
		$config->setProperty('item_news_index',$request->element('item_news_index'));
		$config->setProperty('item_news_per_row',$request->element('item_news_per_row'));
		$config->setProperty('related_news_per_page',$request->element('related_news_per_page'));	
		$config->setProperty('products_per_page',$request->element('products_per_page'));	
		$config->setProperty('image_row_items',$request->element('image_row_items'));
		$config->setProperty('admin_mail',$request->element('admin_mail'));
		$config->setProperty('popup_home',$request->element('popup_home'));
		$config->setProperty('sprice_active',$request->element('sprice_active'));
		$config->setProperty('banner_active',$request->element('banner_active'));
		$config->setProperty('tel',$request->element('tel'));
		$config->setProperty('hotline1',$request->element('hotline1'));	
		$config->setProperty('hotline2',$request->element('hotline2'));	
		$config->setProperty('fax',$request->element('fax'));
		$config->setProperty('tax',$request->element('tax'));
		$config->setProperty('keywords',$request->element('keywords'));
		$config->setProperty('description',$request->element('description'));
		
		$config->setProperty('address',$request->element('address'));
		$config->setProperty('address_eng',$request->element('address_eng'));
		$config->setProperty('company',$request->element('company'));
		$config->setProperty('company_en',$request->element('company_en'));
		$config->setProperty('website',$request->element('website'));
		if($configs->updateData($config)) {
			$infoText = $amessages['update_config_ok'];
			
			$template->assign("InfoText",$infoText);
			$template->assign("infoClass",$infoClass);
		} else {
			$infoText = $amessages['update_config_error'];
			$infoClass = "infoText";
			$template->assign("InfoText",$infoText);
			$template->assign("infoClass",$infoClass);
		}
	}
	else {
		$infoText = $amessages['update_config_error'];
		$infoClass = "infoText";	
		$template->assign("InfoText",$infoText);				
	}
}


$item_news_index = $config->getProperty('item_news_index'); 
$template->assign("item_news_index",$item_news_index);

$item_news_per_row = $config->getProperty('item_news_per_row'); 
$template->assign("item_news_per_row",$item_news_per_row);


$related_news_per_page = $config->getProperty('related_news_per_page'); 
$template->assign("related_news_per_page",$related_news_per_page);

$products_per_page = $config->getProperty('products_per_page'); 
$template->assign("products_per_page",$products_per_page);

$image_row_items = $config->getProperty('image_row_items'); 
$template->assign("image_row_items",$image_row_items);

$admin_mail = $config->getProperty('admin_mail'); 
$template->assign("admin_mail",$admin_mail);

$popup_home = $config->getProperty('popup_home'); 
$template->assign("popup_home",$popup_home);

$banner_active = $config->getProperty('banner_active'); 
$template->assign("banner_active",$banner_active);

$company = $config->getProperty('company'); 
$template->assign("company",$company);

$company_en = $config->getProperty('company_en'); 
$template->assign("company_en",$company_en);


$sprice_active = $config->getProperty('sprice_active'); 
$template->assign("sprice_active",$sprice_active);

$hotline1 = $config->getProperty('hotline1'); 
$template->assign("hotline1",$hotline1);

$hotline2 = $config->getProperty('hotline2'); 
$template->assign("hotline2",$hotline2);

$tel = $config->getProperty('tel'); 
$template->assign("tel",$tel);


$fax = $config->getProperty('fax'); 
$template->assign("fax",$fax);

$tax = $config->getProperty('tax'); 
$template->assign("tax",$tax);

$website = $config->getProperty('website'); 
$template->assign("website",$website);

$keywords = $config->getProperty('keywords'); 
$template->assign("keywords",$keywords);


$description = $config->getProperty('description'); 
$template->assign("description",$description);

$address = $config->getProperty('address'); 
$template->assign("address",$address);


$tel = $config->getProperty('tel'); 
$template->assign("tel",$tel);
$user_login = $config->getProperty('user_login'); 
$template->assign("user_login",$user_login);

$address = $config->getProperty('address'); 
$template->assign("address",$address);
$address_eng = $config->getProperty('address_eng'); 
$template->assign("address_eng",$address_eng);

function validateData($request) {
	global $amessages;
	$infoText = '';
	$validate = new Validate();
	$infoText .= $validate->validInteger($amessages['item_news_index'],$request->element('item_news_index'));
	$infoText .= $validate->validInteger($amessages['item_news_per_row'],$request->element('item_news_per_row'));
	$infoText .= $validate->validInteger($amessages['related_news_per_page'],$request->element('related_news_per_page'));
	$infoText .= $validate->validString($amessages['products_per_page'],$request->element('products_per_page'));
	$infoText .= $validate->validString($amessages['image_row_items'],$request->element('image_row_items'));
	//$infoText .= $validate->validString($amessages['tel'],$request->element('tel'));
	//$infoText .= $validate->validString($amessages['hotline'],$request->element('hotline'));
	//$infoText .= $validate->validString($amessages['fax'],$request->element('fax'));
	//$infoText .= $validate->validString($amessages['address'],$request->element('address'));
	return '';
}


?>